package com.yhl.vocation.util;

import com.alibaba.fastjson2.JSON;

/**
 * @Description
 * @Author Date 2023/2/27-20:11
 */
public class ResUtil {

    public static String build(String code){
        return build(code,null,null);
    }

    public static String build(String code, String message){
        return build(code,message,null);
    }

    public static String build(String code, Object obj){
        return build(code,null, obj);
    }

    public static String build(String code,String message,Object data){
        Message msg = new Message();
        msg.setCode(code);
        msg.setMessage(message);
        msg.setData(data);
        return JSON.toJSONString(msg);
    }

    static class Message{
        private String code;
        private String message;
        private Object data;

        public String getCode() {
            return code;
        }

        public void setCode(String code) {
            this.code = code;
        }

        public String getMessage() {
            return message;
        }

        public void setMessage(String message) {
            this.message = message;
        }

        public Object getData() {
            return data;
        }

        public void setData(Object data) {
            this.data = data;
        }
    }
}
